import request from '../../request'
import { AxiosResponse } from 'axios'
import { LoginFrom } from '@/types/views/login'
import { ResponseData } from '@/types/api/public'
import { TableList,EditData,UserInput } from '@/types/api/syssetting/user'

type ConfigType<T=ResponseData> = Promise<AxiosResponse<T>>

export const getData =(params:any):ConfigType<TableList> =>{
    params.PageIndex=params.current;
    params.PageSize=params.pageSize;
    return request({
       url:'/User/QueryPageUsers',
       method:'get',
       params,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const getDepartmentTreeData = (params:any):ConfigType<TableList> =>{
    return request({
       url:'/Department/QueryAllDepartmentTrees',
       method:'get',
       params,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const getUserDataList =():ConfigType<any> =>{
    return request({
       url:'/User/QueryUsers',
       method:'get',
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const setUser =(data:UserInput):ConfigType =>{
    return request({
       url:'/User/SetUser',
       method:'post',
       data,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const delUser =(params:any):ConfigType =>{
    return request({
       url:'/User/DeleteUser',
       method:'get',
       params,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const getRoleData =(params:any):ConfigType<TableList> =>{
    params.PageIndex=params.current;
    params.PageSize=params.pageSize;
    const data= JSON.stringify(params);
    return request({
       url:'/Role/QueryAllRoles',
       method:'get',
       data,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

